﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using SAC.Helper;
using DAL;
using System.Web;

namespace BLL
{
    /// <summary>
    /// 齐热指标竞赛
    /// 电量报表模块
    /// 
    /// </summary>
    public class BLLPrepQr
    {
        string rtDBType = "";   //实时数据库
        string rlDBType = "";   //关系数据库

        ArrayList list = new ArrayList();
        StrHelper sh = new StrHelper();
        StringBuilder sb = new StringBuilder();
        DALPrepQr dpqr = new DALPrepQr();

        /// <summary>
        /// 初始化函数
        /// </summary>
        private void init()
        {
            rtDBType = IniHelper.ReadIniData("RTDB", "DBType", null);
            rlDBType = IniHelper.ReadIniData("RelationDBbase", "DBType", null);
        }

        /// <summary>
        /// 发电量奖日报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetPowerByDay(string repName, DateTime date)
        {
            ArrayList listRB = new ArrayList();
            ArrayList listYB = new ArrayList();
            string res;
            string res2;
            string qsrqY;
            string jsrqY;
            string qsrq;
            string jsrq;
            string bNameR;
            string bNameY;
            bool isTrueR = false;
            bool isTrueY = false;
            string[] DLday = new string[5];
            string[] PMday = new string[5];
            string[] PMmon = new string[5];
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[24];
            string[] jldt2 = new string[24];
            string[] Dtemp = new string[5];
            string[] BZt = new string[5];
            string[] BZ = new string[5]{"1","2","3","4","5"};
            string[] Btemp = new string[5];
            string[] BZ2 = new string[5];

            DateTime dtNow = DateTime.Now;

            //if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day < date.Day)
            //{ sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            //if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day == date.Day)
            //{
            //    qsrqD = dtNow.ToString("yyyy-MM-dd 00:00:00");

            //    if (dtNow.Hour > 0 && dtNow.Hour < 8)
            //        jsrqD = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
            //    else if (dtNow.Hour > 8 && dtNow.Hour < 16)
            //        jsrqD = dtNow.ToString("yyyy-MM-dd 7:59:59");
            //    else
            //        jsrqD = dtNow.ToString("yyyy-MM-dd 15:59:59");
            //}
            //else
            //{
            //    qsrqD = date.ToString("yyyy-MM-dd 00:00:00");
            //    jsrqD = date.ToString("yyyy-MM-dd 23:59:59");
            //}

            //if (dtNow.Year == date.Year && dtNow.Month == date.Month)
            //{
            //    qsrq = dtNow.ToString("yyyy-MM-01 00:00:00");

            //    if (dtNow.Hour > 0 && dtNow.Hour < 8)
            //        jsrq = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
            //    else if (dtNow.Hour > 8 && dtNow.Hour < 16)
            //        jsrq = dtNow.ToString("yyyy-MM-dd 7:59:59");
            //    else
            //        jsrq = dtNow.ToString("yyyy-MM-dd 15:59:59");
            //}
            //else
            //{
            //    qsrq = sh.FirstDayOfMonth(date).ToString("yyyy-MM-dd H:mm:ss");
            //    jsrq = sh.LastDayOfMonth(date).ToString("yyyy-MM-dd 23:59:59");
            //}
            if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day < date.Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameR = "统计数据值日表";

            if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day == date.Day)
            {
                qsrq = date.ToString("yyyy-MM-dd 0:00:00");
                jsrq = dtNow.ToString("yyyy-MM-dd H:00:00");
                isTrueR = true;
            }
            else
            {
                qsrq = date.ToString("yyyy-MM-dd 0:00:00");
                jsrq = date.ToString("yyyy-MM-dd 23:59:59");
                isTrueR = false;
            }
            bNameY = "统计数据值月表";

            if (dtNow.Year == date.Year && dtNow.Month == date.Month)
            {
                qsrqY = date.ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = true;
            }
            else
            {
                qsrqY = date.ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(date).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = false;
            }

            listRB = dpqr.RetArrsRepValDay("zr", "发电量奖", qsrq, jsrq, bNameR, "0", out bzIDR);
            jldt = (string[])listRB[3];
            res = (string)jldt[3];
            listYB = dpqr.RetArrsRepValDay("zy", "发电量奖", qsrq, jsrq, bNameY, "0", out bzIDY);
            jldt2 = (string[])listYB[3];
            res2 = (string)jldt2[3];
            if (res != "")
            {
                //string[] arr = res.Split('|');
                //string[] BZ = arr[0].TrimEnd(',').Split(',');
                //string[] BZ2 = arr[0].TrimEnd(',').Split(',');
                //string[] DLday = res.TrimEnd(',').Split(',');
                string[] DLmon = res2.TrimEnd(',').Split(',');

                Dtemp = res.TrimEnd(',').Split(',');
                Btemp = bzIDR.TrimEnd(',').Split(',');
                for (int i = 0; i < 3; i++)
                {
                    BZt[int.Parse(Btemp[i])-1] = Btemp[i];
                }
                BZ2 = bzIDY.TrimEnd(',').Split(',');
                int b = 0;
                for (int i = 0; i < 5; i++)
                {
                    if (BZt[i] != null)
                    {
                        DLday[i] = Dtemp[b];
                        b++;
                    }
                    else
                    {
                        DLday[i] = "-";
                    }
                }

                sb.Append("<tr bgcolor=\"#CFE6FC\"><td  align=\"center\">运 行 值</td>");

                for (int i = 0; i < BZ.Length; i++)
                { sb.AppendFormat("<td  align=\"center\" colspan=\"2\">{0}</td>", sh.ConvertChinese(BZ[i].ToString())); }

                sb.Append("</tr>");

                sb.Append("<tr><td  align=\"center\" rowspan=\"2\">发电量</td>");
                sb.Append("<td  align=\"center\">当日</td>");
                sb.Append("<td  align=\"center\">累计</td>");
                sb.Append("<td  align=\"center\">当日</td>");
                sb.Append("<td  align=\"center\">累计</td>");
                sb.Append("<td  align=\"center\">当日</td>");
                sb.Append("<td  align=\"center\">累计</td>");
                sb.Append("<td  align=\"center\">当日</td>");
                sb.Append("<td  align=\"center\">累计</td>");
                sb.Append("<td  align=\"center\">当日</td>");
                sb.Append("<td  align=\"center\">累计</td></tr>");

                sb.Append("<tr>");

                for (int i = 0; i < DLday.Length; i++)
                {
                    if (DLday[i] != null)
                        sb.AppendFormat("<td align=\"center\">{0}</td>", DLday[i]);
                    else
                        sb.Append("<td align=\"center\">&nbsp;</td>");

                    if (DLmon[i] != null)
                        sb.AppendFormat("<td align=\"center\">{0}</td>", DLmon[i]);
                    else
                        sb.Append("<td align=\"center\">&nbsp;</td>");
                }

                sb.Append("</tr>");
                     
                sb.Append("<tr><td  align=\"center\">排名</td>");

                string temp = "";
                for (int i = 0; i < DLday.Length; i++)
                {
                    if (DLday[i] == "-")
                    {
                        DLday[i] = "-1";
                    }
                }

                for (int j = 0; j < DLday.Length; j++)
                {
                    for (int i = DLday.Length - 1; i > j; i--)
                    {
                        if (DLday[i] != null && DLday[j] != null)
                        {
                            if (DLday[i] != "-" && DLday[j] != "-")// if (DLday[i] != "-")
                            {
                                if (double.Parse(DLday[j]) < double.Parse(DLday[i]))
                                {
                                    temp = DLday[j];
                                    DLday[j] = DLday[i];
                                    DLday[i] = temp;

                                    temp = BZ[j];
                                    BZ[j] = BZ[i];
                                    BZ[i] = temp;
                                }
                            }
                        }
                    }
                }

                for (int j = 0; j < DLmon.Length; j++)
                {
                    for (int i = DLmon.Length - 1; i > j; i--)
                    {
                        if (DLmon[i] != null && DLmon[j] != null)
                        {
                            if (DLmon[i] != "-")
                            {
                                if (double.Parse(DLmon[j]) < double.Parse(DLmon[i]))
                                {
                                    temp = DLmon[j];
                                    DLmon[j] = DLmon[i];
                                    DLmon[i] = temp;

                                    temp = BZ2[j];
                                    BZ2[j] = BZ2[i];
                                    BZ2[i] = temp;
                                }
                            }
                        }
                    }
                }
                int k = 0;
                string pm;
                for (int i = 0; i < BZ.Length; i++)
                {
                    int j = int.Parse(BZ[i].ToString());
                    k = i + 1;
                    pm = k.ToString();
                    PMday[j - 1] = pm;
                }
                for (int i = 0; i < BZ2.Length; i++)
                {
                    int j = int.Parse(BZ2[i].ToString());
                    k = i + 1;
                    pm = k.ToString();
                    PMmon[j-1] = pm;
                }
                for (int i = 0; i < BZ.Length; i++)
                {
                    if (PMday[i] == "4" || PMday[i] == "5")
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                    else
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", PMday[i].ToString()); 
                    }
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[i].ToString()); 
                }
                    sb.Append("</tr");
 
            }
            else
                sb.Append("查询出错,请联系管理员解决...");

            return sb.ToString();
        }

        /// <summary>
        /// 发电量奖月报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetPowerByMonth(string repName, DateTime date)
        {
            ArrayList listYB = new ArrayList();
            string res;
            string res2;
            string qsrqY;
            string jsrqY;
            string qsrq;
            string jsrq;
            string bNameR;
            string bNameY;
            bool isTrueR = false;
            bool isTrueY = false;
            string[] DLday = new string[5];
            string[] PMday = new string[5];
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[24];
            string[] jldt2 = new string[24];
            string[] Dtemp = new string[5];
            string[] BZt = new string[5];
            string[] BZ = new string[5] { "1", "2", "3", "4", "5" };
            string[] Btemp = new string[5];
            string[] BZ2 = new string[5];

            DateTime dtNow = DateTime.Now;

            if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day < date.Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameY = "统计数据值月表";

            if (dtNow.Year == date.Year && dtNow.Month == date.Month)
            {
                qsrqY = date.ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = true;
            }
            else
            {
                qsrqY = date.ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(date).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = false;
            }

            listYB = dpqr.RetArrsRepValDay("zy", "发电量奖", qsrqY, jsrqY, bNameY, "0", out bzIDY);
            jldt2 = (string[])listYB[3];
            res = (string)jldt2[3];

            if (res != "")
            {
                string[] DL = res.TrimEnd(',').Split(',');
                BZ = bzIDY.TrimEnd(',').Split(',');
                string[] PMmon = new string[5];

                sb.Append("<tr bgcolor=\"#CFE6FC\"><td  align=\"center\">运 行 值</td>");

                for (int i = 0; i < BZ.Length; i++)
                { sb.AppendFormat(" <td  align=\"center\">{0}</td>", sh.ConvertChinese(BZ[i].ToString())); }

                sb.Append("</tr>");

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">发电量</td>");

                for (int i = 0; i < DL.Length; i++)
                { sb.AppendFormat(" <td  align=\"center\">{0}</td>", DL[i]); }

                sb.Append("</tr>");

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">排名</td>");

                string temp = "";

                for (int j = 0; j < DL.Length; j++)
                {
                    for (int i = DL.Length - 1; i > j; i--)
                    {
                        if (DL[i] != null && DL[j] != null)
                        {
                            if (double.Parse(DL[j]) < double.Parse(DL[i]))
                            {
                                temp = DL[j];
                                DL[j] = DL[i];
                                DL[i] = temp;

                                temp = BZ[j];
                                BZ[j] = BZ[i];
                                BZ[i] = temp;
                            }
                        }
                    }
                }
                int k = 0;
                string pm;
                for (int i = 0; i < BZ.Length; i++)
                {
                    int j = int.Parse(BZ[i].ToString());
                    k = i + 1;
                    pm = k.ToString();
                    PMmon[j - 1] = pm;
                }

                for (int i = 0; i < 5; i++)
                {
                    //int j = i + 1;
                    //for (int k = 0; k < BZ.Length; k++)
                    //{
                    //    if (j == double.Parse(BZ[k].ToString()))
                    //    {
                    //        int t = k + 1;
                    //        sb.AppendFormat("<td  align=\"center\">{0}</td>", t.ToString()); }
                    //}
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[i].ToString());
                }

                sb.Append("</tr>");
            }
            else
                sb.Append("查询出错,请联系管理员解决...");

            return sb.ToString();
        }

        /// <summary>
        /// 小指标竞赛日报
        /// </summary>
        /// <param name="JZ"></param>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetxzbByDay(string unit, string repName, string date, string repType)
        {
            string list1 = "";
            ArrayList listRB = new ArrayList();
            ArrayList listYB = new ArrayList();
            string res;
            string bNameR = "";
            string bNameY = "";
            string arrBZ = null;
            string qsrq="";
            string jsrq="";
            string qsrqY = "";
            string jsrqY = "";
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[24];
            string[] jldt2 = new string[4];
            string[,] jld = new string[24,6];//当日值
            string[] bz = new string[3];//每天当班的班值
            string[,] jlm = new string[24, 6];//累计值
            string[,] jlmdf = new string[24, 5];//累计得分
            string temp;
            string temp2;
            double temp3;
            string[] BZ = new string[5];
            string[] PMmon = new string[5];
            string[,] defen = new string[10,5];
            double[] pjdf = new double[5];
            int k2 = 0;
            string pm;

            DateTime dtNow = DateTime.Now;
            bool isTrueR = false;
            bool isTrueY = false;

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day < DateTime.Parse(date).Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameR = "统计数据值日表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day == DateTime.Parse(date).Day)
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = dtNow.ToString("yyyy-MM-dd H:00:00"); 
                isTrueR = true;
            }
            else
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 23:59:59"); 
                isTrueR = false;
            }

            bNameY = "统计数据值月表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month)
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"); 
                isTrueY = true;
            }
            else
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(DateTime.Parse(date)).ToString("yyyy-MM-dd 23:59:59"); 
                isTrueY = false;
            }
            sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">-</td><td  align=\"center\">内容</td><td  align=\"center\">一值</td><td  align=\"center\">二值</td><td  align=\"center\">三值</td><td  align=\"center\">四值</td><td  align=\"center\">五值</td><td  align=\"center\">累计平均</td></tr>");
            #region 统计日报
            listRB = dpqr.RetArrsRepValDay("zr", repName, qsrq, jsrq, bNameR, unit, out bzIDR);
            bz = bzIDR.TrimEnd(',').Split(',');
            jldt = (string[])listRB[3];
            for (int i = 0; i < 24; i++)
            {
                if (i == 1 || i == 3 || i == 5 || i == 7 || i == 9 || i == 12 || i == 15 || i == 17 || i == 20 || i == 22)
                {
                    jldt2 = jldt[i].TrimEnd(',').Split(',');
                    for (int j = 0; j < 3; j++)
                    {
                        jld[i, int.Parse(bz[j])] = jldt2[j];
                    }
                }
            }
            #endregion

            #region 统计月报
            listYB = dpqr.RetArrsRepValDay("zy", repName, qsrqY, jsrqY, bNameY, unit, out bzIDY);
            jldt = (string[])listYB[3];
            for (int i = 1; i < 24; i++)
            {                
                jldt2 = jldt[i].TrimEnd(',').Split(',');
                for (int j = 0; j < jldt2.Count(); j++)
                {
                    jlm[i, j] = jldt2[j];
                }
            }
            #endregion
            int l = 0;
            #region 厂用电率,真空,给水温度,主蒸汽压力
            for (int i = 1; i <= 7; i=i+2)
            {               
                switch (i)
                {
                    case 1:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">厂用电率</td><td  align=\"center\" width=\"7%\">当日</td>");
                        break;
                    case 3:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">真空</td><td  align=\"center\" width=\"7%\">当日</td>");
                        break;
                    case 5:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">给水温度</td><td  align=\"center\" width=\"7%\">当日</td>");
                        break;
                    case 7:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">主蒸汽压力</td><td  align=\"center\" width=\"7%\">当日</td>");
                        break;
                }
                for (int k = 1; k <= 5; k++)
                {
                    if (jld[i, k] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[i, k]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[i,5]);
                sb.Append("</tr>");

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
                for (int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[i,k]);
                }
                sb.Append("</tr>");
                
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
                for(int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[i+1,k]);
                    defen[l, k] = jlm[i + 1, k];
                }
                sb.Append("</tr>");

                #region 计算每项小指标排名
                BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
                for (int j = 0; j < 5; j++)
                {
                    for (int z = 4; z > j; z--)
                    {
                        if (jlm[i+1, j] != null && jlm[i+1, z] != null)
                        {
                            if (double.Parse(jlm[i+1, j]) < double.Parse(jlm[i+1, z]))
                            {
                                temp = jlm[i+1, j];
                                jlm[i+1, j] = jlm[i+1, z];
                                jlm[i+1, z] = temp;

                                temp2 = BZ[j];
                                BZ[j] = BZ[z];
                                BZ[z] = temp2;
                            }
                        }
                    }
                }
                k2 = 0;
                for (int i2 = 0; i2 < 5; i2++)
                {
                    int j2 = int.Parse(BZ[i2].ToString());
                    k2 = i2 + 1;
                    pm = k2.ToString();
                    PMmon[j2 - 1] = pm;
                }
                if (jlm[i + 1, 0] == jlm[i + 1, 1] && jlm[i + 1, 0] == jlm[i + 1, 2] && jlm[i + 1, 0] == jlm[i + 1, 3] && jlm[i + 1, 0] == jlm[i + 1, 4])
                {
                    for (int i5 = 0; i5 < 5; i5++)
                    {
                        PMmon[i5] = "1";
                    }
                }

                #endregion

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
                for (int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
                }
                sb.Append("</tr>");
                l++;
            }
            #endregion

            #region 主蒸汽温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">主蒸汽温度</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[9, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[9, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[9, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[9, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[9, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[10, k]);
                    defen[4,k] = jlm[10, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[11, k]);
                    defen[4,k] = jlm[11, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[4, j] != null && defen[4, z] != null)
                    {
                        if (double.Parse(defen[4, j]) < double.Parse(defen[4, z]))
                        {
                            temp = defen[4, j];
                            defen[4, j] = defen[4, z];
                            defen[4, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[4, 0] == defen[4, 1] && defen[4, 0] == defen[4, 2] && defen[4, 0] == defen[4, 3] && defen[4, 0] == defen[4, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 再热器温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">再热器温度</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[12, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[12, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[12, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[12, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[12, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[13, k]);
                    defen[5, k] = jlm[13, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[14, k]);
                    defen[5, k] = jlm[14, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[5, j] != null && defen[5, z] != null)
                    {
                        if (double.Parse(defen[5, j]) < double.Parse(defen[5, z]))
                        {
                            temp = defen[5, j];
                            defen[5, j] = defen[5, z];
                            defen[5, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[5, 0] == defen[5, 1] && defen[5, 0] == defen[5, 2] && defen[5, 0] == defen[5, 3] && defen[5, 0] == defen[5, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 再热减温水流量
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">再热减温水流量</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[15, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[15, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[15, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[15, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[16, k]);
                defen[6, k] = jlm[16, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[6, j] != null && defen[6, z] != null)
                    {
                        if (double.Parse(defen[6, j]) < double.Parse(defen[6, z]))
                        {
                            temp = defen[6, j];
                            defen[6, j] = defen[6, z];
                            defen[6, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[6, 0] == defen[6, 1] && defen[6, 0] == defen[6, 2] && defen[6, 0] == defen[6, 3] && defen[6, 0] == defen[6, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 排烟温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">排烟温度</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[17, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[17, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[17, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[17, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[17, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[18, k]);
                    defen[7, k] = jlm[18, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[19, k]);
                    defen[7, k] = jlm[19, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[7, j] != null && defen[7, z] != null)
                    {
                        if (double.Parse(defen[7, j]) < double.Parse(defen[7, z]))
                        {
                            temp = defen[7, j];
                            defen[7, j] = defen[7, z];
                            defen[7, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[7, 0] == defen[7, 1] && defen[7, 0] == defen[7, 2] && defen[7, 0] == defen[7, 3] && defen[7, 0] == defen[7, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 排烟氧量
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">排烟氧量</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[20, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[20, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[20, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[20, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[21, k]);
                defen[8, k] = jlm[21, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[8, j] != null && defen[8, z] != null)
                    {
                        if (double.Parse(defen[8, j]) < double.Parse(defen[8, z]))
                        {
                            temp = defen[8, j];
                            defen[8, j] = defen[8, z];
                            defen[8, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[8, 0] == defen[8, 1] && defen[8, 0] == defen[8, 2] && defen[8, 0] == defen[8, 3] && defen[8, 0] == defen[8, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 补水率
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"4\" width=\"12%\">补水率</td><td  align=\"center\" width=\"7%\">当日</td>");
            for (int k = 1; k <= 5; k++)
            {
                if (jld[22, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[22, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"4\" width=\"10%\">{0}</td>", jlm[22, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[22, k]);
            }
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[23, k]);
                defen[9, k] = jlm[23, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[9, j] != null && defen[9, z] != null)
                    {
                        if (double.Parse(defen[9, j]) < double.Parse(defen[9, z]))
                        {
                            temp = defen[9, j];
                            defen[9, j] = defen[8, z];
                            defen[9, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[9, 0] == defen[9, 1] && defen[9, 0] == defen[9, 2] && defen[9, 0] == defen[9, 3] && defen[9, 0] == defen[9, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            for (int i = 0; i < 5; i++)
            {
                temp3 = 0;
                for (int j = 0; j < 10; j++)
                {
                    temp3 = temp3 + double.Parse(defen[j, i]);
                }
                pjdf[i] = temp3 / 10;
            }

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"12%\">平均得分</td>");
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", pjdf[i].ToString());
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            #region 计算总排名
            string temp22;
            string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };
            string[] PMmon2 = new string[5];
            for (int j3 = 0; j3 < 5; j3++)
            {
                for (int z3 = 4; z3 > j3; z3--)
                {
                    if (pjdf[j3] != 0 && pjdf[j3] != 0)
                    {
                        if (pjdf[j3] < pjdf[z3])
                        {
                            temp3 = pjdf[j3];
                            pjdf[j3] = pjdf[z3];
                            pjdf[z3] = temp3;

                            temp22 = BZ2[j3];
                            BZ2[j3] = BZ2[z3];
                            BZ2[z3] = temp22;
                        }
                    }
                }
            }
            int k22 = 0;
            string pm2;
            for (int i22 = 0; i22 < 5; i22++)
            {
                int j22 = int.Parse(BZ2[i22].ToString());
                k22 = i22 + 1;
                pm2 = k22.ToString();
                PMmon2[j22 - 1] = pm2;
            }
            if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
            {
                for (int i4 = 0; i4 < 5; i4++)
                {
                    PMmon2[i4] = "1";
                }
            }

            #endregion

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"12%\">总排名</td>");
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i]);
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            return sb.ToString();

        }

        /// <summary>
        /// 小指标竞赛月报
        /// </summary>
        /// <param name="JZ"></param>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetxzbByMonth(string unit, string repName, string date, string repType)
        {
            string list1 = "";
            ArrayList listRB = new ArrayList();
            ArrayList listYB = new ArrayList();
            string res;
            string bNameR = "";
            string bNameY = "";
            string arrBZ = null;
            string qsrq = "";
            string jsrq = "";
            string qsrqY = "";
            string jsrqY = "";
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[24];
            string[] jldt2 = new string[4];
            string[,] jld = new string[24, 6];//当日值
            string[] bz = new string[3];//每天当班的班值
            string[,] jlm = new string[24, 6];//累计值
            string[,] jlmdf = new string[24, 5];//累计得分
            string temp;
            string temp2;
            double temp3;
            string[] BZ = new string[5];
            string[] PMmon = new string[5];
            string[,] defen = new string[10, 5];
            double[] pjdf = new double[5];
            int k2 = 0;
            string pm;

            DateTime dtNow = DateTime.Now;
            bool isTrueR = false;
            bool isTrueY = false;

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day < DateTime.Parse(date).Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameR = "统计数据值日表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day == DateTime.Parse(date).Day)
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = dtNow.ToString("yyyy-MM-dd H:00:00");
                isTrueR = true;
            }
            else
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 23:59:59");
                isTrueR = false;
            }

            bNameY = "统计数据值月表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month)
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = true;
            }
            else
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(DateTime.Parse(date)).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = false;
            }

            #region 统计月报
            listYB = dpqr.RetArrsRepValDay("zy", repName, qsrqY, jsrqY, bNameY, unit, out bzIDY);
            jldt = (string[])listYB[3];
            for (int i = 1; i < 24; i++)
            {
                jldt2 = jldt[i].TrimEnd(',').Split(',');
                for (int j = 0; j < jldt2.Count(); j++)
                {
                    jlm[i, j] = jldt2[j];
                }
            }
            #endregion
            int l = 0;
            #region 厂用电率,真空,给水温度,主蒸汽压力
            for (int i = 1; i <= 7; i = i + 2)
            {
                switch (i)
                {
                    case 1:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">厂用电率</td><td  align=\"center\" width=\"7%\">累计</td>");
                        break;
                    case 3:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">真空</td><td  align=\"center\" width=\"7%\">累计</td>");
                        break;
                    case 5:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">给水温度</td><td  align=\"center\" width=\"7%\">累计</td>");
                        break;
                    case 7:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">主蒸汽压力</td><td  align=\"center\" width=\"7%\">累计</td>");
                        break;
                }
                for (int k = 0; k < 5; k++)
                {
                    if (jlm[i, k] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[i, k]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[i, 5]);
                sb.Append("</tr>");

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
                for (int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[i + 1, k]);
                    defen[l, k] = jlm[i + 1, k];
                }
                sb.Append("</tr>");

                #region 计算每项小指标排名
                BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
                for (int j = 0; j < 5; j++)
                {
                    for (int z = 4; z > j; z--)
                    {
                        if (jlm[i + 1, j] != null && jlm[i + 1, z] != null)
                        {
                            if (double.Parse(jlm[i + 1, j]) < double.Parse(jlm[i + 1, z]))
                            {
                                temp = jlm[i + 1, j];
                                jlm[i + 1, j] = jlm[i + 1, z];
                                jlm[i + 1, z] = temp;

                                temp2 = BZ[j];
                                BZ[j] = BZ[z];
                                BZ[z] = temp2;
                            }
                        }
                    }
                }
                k2 = 0;
                for (int i2 = 0; i2 < 5; i2++)
                {
                    int j2 = int.Parse(BZ[i2].ToString());
                    k2 = i2 + 1;
                    pm = k2.ToString();
                    PMmon[j2 - 1] = pm;
                }
                if (jlm[i + 1, 0] == jlm[i + 1, 1] && jlm[i + 1, 0] == jlm[i + 1, 2] && jlm[i + 1, 0] == jlm[i + 1, 3] && jlm[i + 1, 0] == jlm[i + 1, 4])
                {
                    for (int i5 = 0; i5 < 5; i5++)
                    {
                        PMmon[i5] = "1";
                    }
                }

                #endregion

                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
                for (int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
                }
                sb.Append("</tr>");
                l++;

            }
            #endregion

            #region 主蒸汽温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">主蒸汽温度</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[9, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[9, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[9, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[9, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[10, k]);
                    defen[4, k] = jlm[10, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[11, k]);
                    defen[4, k] = jlm[11, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[4, j] != null && defen[4, z] != null)
                    {
                        if (double.Parse(defen[4, j]) < double.Parse(defen[4, z]))
                        {
                            temp = defen[4, j];
                            defen[4, j] = defen[4, z];
                            defen[4, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[4, 0] == defen[4, 1] && defen[4, 0] == defen[4, 2] && defen[4, 0] == defen[4, 3] && defen[4, 0] == defen[4, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 再热器温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">再热器温度</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[12, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[12, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[12, 5]);
            sb.Append("</tr>");

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[12, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[13, k]);
                    defen[5, k] = jlm[13, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[14, k]);
                    defen[5, k] = jlm[14, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[5, j] != null && defen[5, z] != null)
                    {
                        if (double.Parse(defen[5, j]) < double.Parse(defen[5, z]))
                        {
                            temp = defen[5, j];
                            defen[5, j] = defen[5, z];
                            defen[5, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[5, 0] == defen[5, 1] && defen[5, 0] == defen[5, 2] && defen[5, 0] == defen[5, 3] && defen[5, 0] == defen[5, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 再热减温水流量
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">再热减温水流量</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[15, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[15, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[15, 5]);
            sb.Append("</tr>");

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[16, k]);
                defen[6, k] = jlm[16, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[6, j] != null && defen[6, z] != null)
                    {
                        if (double.Parse(defen[6, j]) < double.Parse(defen[6, z]))
                        {
                            temp = defen[6, j];
                            defen[6, j] = defen[6, z];
                            defen[6, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[6, 0] == defen[6, 1] && defen[6, 0] == defen[6, 2] && defen[6, 0] == defen[6, 3] && defen[6, 0] == defen[6, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 排烟温度（涉及双重评分标准）
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">排烟温度</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[17, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[17, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[17, 5]);
            sb.Append("</tr>");

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                if (double.Parse(jlm[17, k]) <= 545)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[18, k]);
                    defen[7, k] = jlm[18, k];
                }
                else
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[19, k]);
                    defen[7, k] = jlm[19, k];
                }
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[7, j] != null && defen[7, z] != null)
                    {
                        if (double.Parse(defen[7, j]) < double.Parse(defen[7, z]))
                        {
                            temp = defen[7, j];
                            defen[7, j] = defen[7, z];
                            defen[7, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[7, 0] == defen[7, 1] && defen[7, 0] == defen[7, 2] && defen[7, 0] == defen[7, 3] && defen[7, 0] == defen[7, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 排烟氧量
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">排烟氧量</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[20, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[20, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[20, 5]);
            sb.Append("</tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[21, k]);
                defen[8, k] = jlm[21, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[8, j] != null && defen[8, z] != null)
                    {
                        if (double.Parse(defen[8, j]) < double.Parse(defen[8, z]))
                        {
                            temp = defen[8, j];
                            defen[8, j] = defen[8, z];
                            defen[8, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[8, 0] == defen[8, 1] && defen[8, 0] == defen[8, 2] && defen[8, 0] == defen[8, 3] && defen[8, 0] == defen[8, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            #region 补水率
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">补水率</td><td  align=\"center\" width=\"7%\">累计</td>");
            for (int k = 0; k < 5; k++)
            {
                if (jlm[22, k] != null)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[22, k]);
                }
                else
                {
                    sb.Append("<td  align=\"center\">-</td>");
                }
            }
            sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[22, 5]);
            sb.Append("</tr>");
 
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">得分</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[23, k]);
                defen[9, k] = jlm[23, k];
            }
            sb.Append("</tr>");
            #region 计算每项小指标排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (defen[9, j] != null && defen[9, z] != null)
                    {
                        if (double.Parse(defen[9, j]) < double.Parse(defen[9, z]))
                        {
                            temp = defen[9, j];
                            defen[9, j] = defen[8, z];
                            defen[9, z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (defen[9, 0] == defen[9, 1] && defen[9, 0] == defen[9, 2] && defen[9, 0] == defen[9, 3] && defen[9, 0] == defen[9, 4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"5%\">排名</td>");
            for (int k = 0; k < 5; k++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
            }
            sb.Append("</tr>");
            #endregion

            for (int i = 0; i < 5; i++)
            {
                temp3 = 0;
                for (int j = 0; j < 10; j++)
                {
                    temp3 = temp3 + double.Parse(defen[j, i]);
                }
                pjdf[i] = temp3 / 10;
            }

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"12%\">平均得分</td>");
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", pjdf[i].ToString());
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            #region 计算总排名
            string temp22;
            string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };
            string[] PMmon2 = new string[5];
            for (int j3 = 0; j3 < 5; j3++)
            {
                for (int z3 = 4; z3 > j3; z3--)
                {
                    if (pjdf[j3] != 0 && pjdf[j3] != 0)
                    {
                        if (pjdf[j3] < pjdf[z3])
                        {
                            temp3 = pjdf[j3];
                            pjdf[j3] = pjdf[z3];
                            pjdf[z3] = temp3;

                            temp22 = BZ2[j3];
                            BZ2[j3] = BZ2[z3];
                            BZ2[z3] = temp22;
                        }
                    }
                }
            }
            int k22 = 0;
            string pm2;
            for (int i22 = 0; i22 < 5; i22++)
            {
                int j22 = int.Parse(BZ2[i22].ToString());
                k22 = i22 + 1;
                pm2 = k22.ToString();
                PMmon2[j22 - 1] = pm2;
            }
            if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
            {
                for (int i4 = 0; i4 < 5; i4++)
                {
                    PMmon2[i4] = "1";
                }
            }

            #endregion

            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"12%\">总排名</td>");
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i]);
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            return sb.ToString();

        }

        /// <summary>
        /// 辅机单耗日报
        /// </summary>
        /// <param name="JZ"></param>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetfjByDay(string unit, string repName, string date, string repType)
        {
            string strdata = "0";
            string xzb = "";

            string list1 = "";
            ArrayList listRB = new ArrayList();
            ArrayList listYB = new ArrayList();
            string res;
            string bNameR = "";
            string bNameY = "";
            string arrBZ = null;
            string qsrq = "";
            string jsrq = "";
            string qsrqY = "";
            string jsrqY = "";
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[4];
            double[] khz = new double[8];
            string[] jldt2 = new string[6];
            string[,] jld = new string[8, 6];//当日值
            string[] bz = new string[3];//每天当班的班值
            string[,] jlm = new string[8, 6];//累计值
            string[,] jlmdf = new string[8, 5];//累计得分
            string temp;
            string temp2;
            double temp3;
            string[] BZ = new string[5];
            string[] PMmon = new string[5];
            string[,] defen = new string[8, 5];
            double[] pjdf = new double[5];
            int k2 = 0;
            string pm;

            DateTime dtNow = DateTime.Now;
            bool isTrueR = false;
            bool isTrueY = false;

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day < DateTime.Parse(date).Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameR = "统计数据值日表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day == DateTime.Parse(date).Day)
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = dtNow.ToString("yyyy-MM-dd H:00:00");
                isTrueR = true;
            }
            else
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 23:59:59");
                isTrueR = false;
            }

            bNameY = "统计数据值月表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month)
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = true;
            }
            else
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(DateTime.Parse(date)).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = false;
            }
            #region 统计日报
            listRB = dpqr.RetArrsRepValDay("zr", repName, qsrq, jsrq, bNameR, unit, out bzIDR);
            bz = bzIDR.TrimEnd(',').Split(',');
            jldt = (string[])listRB[3];
            for (int i = 0; i < 8; i++)
            {
                jldt2 = jldt[i + 1].TrimEnd(',').Split(',');
                for (int j = 0; j < 3; j++)
                {
                    jld[i, int.Parse(bz[j])] = jldt2[j];
                }
            }
            #endregion

            #region 统计月报
            listYB = dpqr.RetArrsRepValDay("zy", repName, qsrqY, jsrqY, bNameY, unit, out bzIDY);
            jldt = (string[])listYB[3];
            for (int i = 0; i < 8; i++)
            {
                jldt2 = jldt[i+1].TrimEnd(',').Split(',');
                for (int j = 0; j < jldt2.Count(); j++)
                {
                    jlm[i, j] = jldt2[j];
                }
                khz[i] = double.Parse(jlm[i, 5]) * 1.001;
            }
            #endregion
            sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">设备单耗</td><td  align=\"center\">考核值</td><td  align=\"center\">内容</td><td  align=\"center\">一值</td><td  align=\"center\">二值</td><td  align=\"center\">三值</td><td  align=\"center\">四值</td><td  align=\"center\">五值</td><td  align=\"center\">累计平均</td></tr>");
            for (int i = 0; i < 8; i++)
            {
                switch (i)
                {
                    case 0:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">给水单耗耗电率</td>");
                        break;
                    case 1:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">水循环单耗</td>");
                        break;
                    case 2:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">一次风机单耗</td>");
                        break;
                    case 3:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">磨煤机单耗</td>");
                        break;
                    case 4:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">引风机单耗</td>");
                        break;
                    case 5:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">送风机单耗</td>");
                        break;
                    case 6:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">脱硫系统单耗</td>");
                        break;
                    case 7:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"3\" width=\"12%\">电除尘系统单耗</td>");
                        break;
                }

                sb.AppendFormat("<td rowspan=\"3\" align=\"center\">{0}</td>", khz[i].ToString());
                sb.Append("<td  align=\"center\" width=\"5%\">当日</td>");
                for (int k = 0; k < 5; k++)
                {
                    if (jld[i, k] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", jld[i, k]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.AppendFormat("<td  align=\"center\" rowspan=\"3\" width=\"10%\">{0}</td>", jlm[i, 5]);
                sb.Append("</tr>");

                sb.Append("<td  align=\"center\" width=\"5%\">累计</td>");
                for (int k = 0; k < 5; k++)
                {
                    if (jlm[i, k] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", jlm[i, k]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<td  align=\"center\" width=\"5%\">排名</td>");
                #region 计算每项单耗排名
                BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
                for (int j = 0; j < 5; j++)
                {
                    for (int z = 4; z > j; z--)
                    {
                        if (jlm[i, j] != null && jlm[i, z] != null)
                        {
                            if (double.Parse(jlm[i, j]) < double.Parse(jlm[i, z]))
                            {
                                temp = jlm[i, j];
                                jlm[i, j] = jlm[i, z];
                                jlm[i, z] = temp;

                                temp2 = BZ[j];
                                BZ[j] = BZ[z];
                                BZ[z] = temp2;
                            }
                        }
                    }
                }
                k2 = 0;
                for (int i2 = 0; i2 < 5; i2++)
                {
                    int j2 = int.Parse(BZ[i2].ToString());
                    k2 = i2 + 1;
                    pm = k2.ToString();
                    PMmon[j2 - 1] = pm;
                }
                if (jlm[i, 0] == jlm[i, 1] && jlm[i, 0] == jlm[i, 2] && jlm[i, 0] == jlm[i, 3] && jlm[i, 0] == jlm[i, 4])
                {
                    for (int i5 = 0; i5 < 5; i5++)
                    {
                        PMmon[i5] = "1";
                    }
                }

                #endregion
                for (int k = 0; k < 5; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon[k]);
                }
                sb.Append("</tr>");
            }


            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"3\" width=\"12%\">总排名</td>");
            #region 计算总排名
            string temp22;
            string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };
            string[] PMmon2 = new string[5];
            for (int j3 = 0; j3 < 5; j3++)
            {
                for (int z3 = 4; z3 > j3; z3--)
                {
                    if (pjdf[j3] != 0 && pjdf[j3] != 0)
                    {
                        if (pjdf[j3] < pjdf[z3])
                        {
                            temp3 = pjdf[j3];
                            pjdf[j3] = pjdf[z3];
                            pjdf[z3] = temp3;

                            temp22 = BZ2[j3];
                            BZ2[j3] = BZ2[z3];
                            BZ2[z3] = temp22;
                        }
                    }
                }
            }
            int k22 = 0;
            string pm2;
            for (int i22 = 0; i22 < 5; i22++)
            {
                int j22 = int.Parse(BZ2[i22].ToString());
                k22 = i22 + 1;
                pm2 = k22.ToString();
                PMmon2[j22 - 1] = pm2;
            }
            if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
            {
                for (int i4 = 0; i4 < 5; i4++)
                {
                    PMmon2[i4] = "1";
                }
            }

            #endregion
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i]);
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            return sb.ToString();

        }

        /// <summary>
        /// 辅机单耗月报
        /// </summary>
        /// <param name="JZ"></param>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetfjByMonth(int JZ, string repName, DateTime date)
        {
            string strdata = "0";
            string xzb = "";
            sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">设备单耗</td><td  align=\"center\">考核值</td><td  align=\"center\">内容</td><td  align=\"center\">一值</td><td  align=\"center\">二值</td><td  align=\"center\">三值</td><td  align=\"center\">四值</td><td  align=\"center\">五值</td><td  align=\"center\">累计平均</td></tr>");
            for (int i = 0; i < 8; i++)
            {
                switch (i)
                {
                    case 0:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">给水单耗耗电率</td>");
                        break;
                    case 1:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">水循环单耗</td>");
                        break;
                    case 2:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">一次风机单耗</td>");
                        break;
                    case 3:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">磨煤机单耗</td>");
                        break;
                    case 4:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">引风机单耗</td>");
                        break;
                    case 5:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">送风机单耗</td>");
                        break;
                    case 6:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">脱硫系统单耗</td>");
                        break;
                    case 7:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"2\" width=\"12%\">电除尘系统单耗</td>");
                        break;
                }
                for (int j = 0; j < 2; j++)
                {

                    switch (j)
                    {
                        case 0:
                            sb.AppendFormat("<td  align=\"center\" width=\"10%\">{0}</td>", strdata);
                            sb.Append("<td  align=\"center\" width=\"5%\">累计</td>");
                            break;
                        case 1:
                            sb.AppendFormat("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" width=\"10%\">{0}</td>", strdata);
                            sb.Append("<td  align=\"center\" width=\"5%\">排名</td>");
                            break;
                    }
                    for (int k = 0; k < 5; k++)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", strdata);
                    }
                    if (j == 0)
                    {
                        sb.AppendFormat("<td  align=\"center\" rowspan=\"2\" width=\"10%\">{0}</td>", strdata);
                    }
                    sb.Append("</tr>");
                }

            }
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"3\" width=\"12%\">总排名</td>");
            for (int i = 0; i < 5; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", strdata);
            }
            sb.Append("<td  align=\"center\">-</td>");
            sb.Append("</tr>");

            return sb.ToString();

        }

        /// <summary>
        /// 金额分配总表
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetjeByMonth(string date)
        {
            string strdata = "0";
            string xzb = "";

            string list1 = "";
            ArrayList listRB = new ArrayList();
            ArrayList listYB = new ArrayList();
            ArrayList SlistYB = new ArrayList();
            string res;
            string bNameR = "";
            string bNameY = "";
            string arrBZ = null;
            string qsrq = "";
            string jsrq = "";
            string qsrqY = "";
            string jsrqY = "";
            string bzIDR;
            string bzIDY;
            string[] jldt = new string[24];
            double[] khz = new double[8];
            string[] jldt2 = new string[10];
            string[] Sjldt = new string[24];
            string[] Sjldt2 = new string[5];
            string[,] jld = new string[24, 6];//当日值
            string[] bz = new string[3];//每天当班的班值
            string[,] jlm = new string[24, 6];//小指标累计值
            string[,] jlmf = new string[8, 6];//辅机单耗累计值
            string[,] jlmf2 = new string[8, 6];//辅机单耗累计值备用
            string[,] jlmdf = new string[24, 5];//累计得分
            double[,] jine = new double[11, 6];//具体金额
            double djine;//单项辅机金额
            string temp;
            string temp2;
            double temp3;
            string[] BZ = new string[5];
            string[] PMmon = new string[5];
            string[] SPMmon = new string[5];
            string[,] defen = new string[10, 5];
            double[] pjdf = new double[5];
            int k2 = 0;
            string pm;

            DateTime dtNow = DateTime.Now;
            bool isTrueR = false;
            bool isTrueY = false;

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day < DateTime.Parse(date).Day)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            bNameR = "统计数据值日表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month && dtNow.Day == DateTime.Parse(date).Day)
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = dtNow.ToString("yyyy-MM-dd H:00:00");
                isTrueR = true;
            }
            else
            {
                qsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");
                jsrq = DateTime.Parse(date).ToString("yyyy-MM-dd 23:59:59");
                isTrueR = false;
            }

            bNameY = "统计数据值月表";

            if (dtNow.Year == DateTime.Parse(date).Year && dtNow.Month == DateTime.Parse(date).Month)
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = dtNow.AddDays(-1).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = true;
            }
            else
            {
                qsrqY = DateTime.Parse(date).ToString("yyyy-MM-01 0:00:00");
                jsrqY = sh.LastDayOfMonth(DateTime.Parse(date)).ToString("yyyy-MM-dd 23:59:59");
                isTrueY = false;
            }
            string SqsrqY = DateTime.Parse(date).AddMonths(-1).ToString("yyyy-MM-01 0:00:00");
            string SjsrqY = sh.LastDayOfMonth(DateTime.Parse(date).AddMonths(-1)).ToString("yyyy-MM-dd 23:59:59");

            sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\" colspan=\"2\">-</td><td  align=\"center\">一值</td><td  align=\"center\">二值</td><td  align=\"center\">三值</td><td  align=\"center\">四值</td><td  align=\"center\">五值</td><td  align=\"center\" width=\"15%\">各项金额总计</td></tr>");
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"20%\">发电量奖</td>");
            #region 计算发电量奖
            listYB = dpqr.RetArrsRepValDay("zy", "发电量奖", qsrqY, jsrqY, bNameY, "0", out bzIDY);//查询的月份的数据
            jldt = (string[])listYB[3];
            temp = (string)jldt[3];
            jldt2 = temp.TrimEnd(',').Split(',');
            //jldt2[0] = "3.24"; jldt2[1] = "5.76"; jldt2[2] = "2.55"; jldt2[3] = "9.18"; jldt2[4] = "4.30";//测试
            SlistYB = dpqr.RetArrsRepValDay("zy", "发电量奖", SqsrqY, SjsrqY, bNameY, "0", out bzIDY);//查询月份上个月的数据
            Sjldt = (string[])SlistYB[3];
            temp = (string)Sjldt[3];
            Sjldt2 = temp.TrimEnd(',').Split(',');
            //Sjldt2[0] = "5.24"; Sjldt2[1] = "9.76"; Sjldt2[2] = "9.55"; Sjldt2[3] = "3.18"; Sjldt2[4] = "7.30";//测试
            #region 计算查询月份发电量奖排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (jldt2[j] != null && jldt2[z] != null)
                    {
                        if (double.Parse(jldt2[j]) < double.Parse(jldt2[z]))
                        {
                            temp = jldt2[j];
                            jldt2[j] = jldt2[z];
                            jldt2[z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                PMmon[j2 - 1] = pm;
            }
            if (jldt2[0] == jldt2[1] && jldt2[0] == jldt2[2] && jldt2[0] == jldt2[3] && jldt2[0] == jldt2[4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    PMmon[i5] = "1";
                }
            }

            #endregion
            #region 计算查询月份上个月份的发电量奖排名
            BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
            for (int j = 0; j < 5; j++)
            {
                for (int z = 4; z > j; z--)
                {
                    if (Sjldt2[j] != null && Sjldt2[z] != null)
                    {
                        if (double.Parse(Sjldt2[j]) < double.Parse(Sjldt2[z]))
                        {
                            temp = Sjldt2[j];
                            Sjldt2[j] = Sjldt2[z];
                            Sjldt2[z] = temp;

                            temp2 = BZ[j];
                            BZ[j] = BZ[z];
                            BZ[z] = temp2;
                        }
                    }
                }
            }
            k2 = 0;
            for (int i2 = 0; i2 < 5; i2++)
            {
                int j2 = int.Parse(BZ[i2].ToString());
                k2 = i2 + 1;
                pm = k2.ToString();
                SPMmon[j2 - 1] = pm;
            }
            if (Sjldt2[0] == Sjldt2[1] && Sjldt2[0] == Sjldt2[2] && Sjldt2[0] == Sjldt2[3] && Sjldt2[0] == Sjldt2[4])
            {
                for (int i5 = 0; i5 < 5; i5++)
                {
                    SPMmon[i5] = "1";
                }
            }

            #endregion
            for (int i = 0; i < 5; i++)
            {
                switch (PMmon[i])
                {
                    case "1":
                        jine[0, i] = 1000;
                        break;
                    case "2":
                        jine[0, i] = 800;
                        break;
                    case "3":
                        jine[0, i] = 500;
                        break;
                    case "5":
                        if (SPMmon[i] == "5")//如果上个月也是第五名，则考核500元
                        {
                            jine[0, i] = -500;
                        }
                        break;
                }
                jine[0, 5] = jine[0, 5] + jine[0, i];
            }
            #endregion
            for (int i = 0; i < 6; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jine[0,i].ToString());
            }
            sb.Append("</tr>");
            #region 计算小指标竞赛
            listYB = dpqr.RetArrsRepValDay("zy", "小指标考核", qsrqY, jsrqY, bNameY, "0", out bzIDY);
            jldt = (string[])listYB[3];
            for (int i = 1; i < 24; i++)
            {
                jldt2 = jldt[i].TrimEnd(',').Split(',');
                for (int j = 0; j < jldt2.Count(); j++)
                {
                    jlm[i, j] = jldt2[j];
                }
            }
            #region 统计各个得分
            for (int k = 0; k < 4; k++)
            {
                for (int k1 = 0; k1 < 5; k1++)
                {
                    defen[k, k1] = jlm[k * 2 + 2, k1];
                }
            }
            for (int k = 0; k < 5; k++)//主蒸汽温度
            {
                if (double.Parse(jlm[9, k]) <= 545)
                {
                    defen[4, k] = jlm[10, k];
                }
                else
                {
                    defen[4, k] = jlm[11, k];
                }
            }

            for (int k = 0; k < 5; k++)//再热器温度
            {
                if (double.Parse(jlm[12, k]) <= 545)
                {
                    defen[5, k] = jlm[13, k];
                }
                else
                {
                    defen[5, k] = jlm[14, k];
                }
            }
            for (int k = 0; k < 5; k++)
            {
                defen[6, k] = jlm[16, k];
            }
            for (int k = 0; k < 5; k++)//排烟温度
            {
                if (double.Parse(jlm[17, k]) <= 545)
                {
                    defen[7, k] = jlm[18, k];
                }
                else
                {
                    defen[7, k] = jlm[19, k];
                }
            }
            for (int k = 0; k < 2; k++)
            {
                for (int k1 = 0; k1 < 5; k1++)
                {
                    defen[k+8, k1] = jlm[k*2+21, k1];
                }
            }
            #endregion
            for (int i = 0; i < 5; i++)//计算总得分
            {
                temp3 = 0;
                for (int j = 0; j < 10; j++)
                {
                    temp3 = temp3 + double.Parse(defen[j, i]);
                }
                pjdf[i] = temp3 / 10;
            }
            //pjdf[0] = 2; pjdf[1] = 1; pjdf[2] = 5; pjdf[3] = 4; pjdf[4] = 3;//测试
            #region 计算总排名
            string temp22;
            string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };
            string[] PMmon2 = new string[5];
            for (int j3 = 0; j3 < 5; j3++)
            {
                for (int z3 = 4; z3 > j3; z3--)
                {
                    if (pjdf[j3] != 0 && pjdf[j3] != 0)
                    {
                        if (pjdf[j3] < pjdf[z3])
                        {
                            temp3 = pjdf[j3];
                            pjdf[j3] = pjdf[z3];
                            pjdf[z3] = temp3;

                            temp22 = BZ2[j3];
                            BZ2[j3] = BZ2[z3];
                            BZ2[z3] = temp22;
                        }
                    }
                }
            }
            int k22 = 0;
            string pm2;
            for (int i22 = 0; i22 < 5; i22++)
            {
                int j22 = int.Parse(BZ2[i22].ToString());
                k22 = i22 + 1;
                pm2 = k22.ToString();
                PMmon2[j22 - 1] = pm2;
            }
            if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
            {
                for (int i4 = 0; i4 < 5; i4++)
                {
                    PMmon2[i4] = "1";
                }
            }
            #endregion
            for (int i = 0; i < 5; i++)//计算奖金
            {
                switch (PMmon2[i])
                {
                    case "1":
                        jine[1, i] = 1200+3000;
                        break;
                    case "2":
                        jine[1, i] = 1200+2500;
                        break;
                    case "3":
                        jine[1, i] = 1200+2000;
                        break;
                    case "4":
                        jine[1, i] = 1200 + 1500;
                        break;
                    case "5":
                        jine[1, i] = 1200;
                        break;
                }
                jine[1, 5] = jine[1, 5] + jine[1, i];
            }
            
            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\" width=\"20%\">小指标竞赛</td>");
            for (int i = 0; i < 6; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jine[1,i].ToString());
            }
            sb.Append("</tr>");
            #region 计算辅机单耗
            listYB = dpqr.RetArrsRepValDay("zy", "辅机单耗奖励", qsrqY, jsrqY, bNameY, "0", out bzIDY);
            jldt = (string[])listYB[3];
            for (int i = 0; i < 8; i++)
            {
                jldt2 = jldt[i + 1].TrimEnd(',').Split(',');
                for (int j = 0; j < 6; j++)
                {
                    jlmf[i, j] = jldt2[j];
                    jlmf2[i, j] = jldt2[j];
                }
                khz[i] = double.Parse(jlmf[i, 5]) * 1.001;//考核值
            }
            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" rowspan=\"8\" width=\"3%\">辅机单耗奖励项目</td>");
            for(int i=0;i<8;i++)
            {
                switch (i)
                {
                    case 0:
                        sb.Append("<td  align=\"center\" bgcolor=\"#CFE6FC\">给水系统</td>");
                        break;
                    case 1:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">循环水系统</td>");
                        break;
                    case 2:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">一次风机</td>");
                        break;
                    case 3:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">磨煤机</td>");
                        break;
                    case 4:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">引风机</td>");
                        break;
                    case 5:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">送风机</td>");
                        break;
                    case 6:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">脱硫</td>");
                        break;
                    case 7:
                        sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\">电除尘</td>");
                        break;
                }
                #region 计算每项单耗的奖金
                //jlmf[i, 0] = "1.3"; jlmf[i, 1] = "1.1"; jlmf[i, 2] = "1.4"; jlmf[i, 3] = "1.5"; jlmf[i, 4] = "1.2";//测试
                //jlmf2[i, 0] = "1.3"; jlmf2[i, 1] = "1.1"; jlmf2[i, 2] = "1.4"; jlmf2[i, 3] = "1.5"; jlmf2[i, 4] = "1.2";//测试
                //khz[i] = 1.0;//测试
                #region 计算排名
                BZ[0] = "1"; BZ[1] = "2"; BZ[2] = "3"; BZ[3] = "4"; BZ[4] = "5";
                for (int j = 0; j < 5; j++)
                {
                    for (int z = 4; z > j; z--)
                    {
                        if (jlmf[i, j] != null && jlmf[i, z] != null)
                        {
                            if (double.Parse(jlmf[i, j]) < double.Parse(jlmf[i, z]))
                            {
                                temp = jlmf[i, j];
                                jlmf[i, j] = jlmf[i, z];
                                jlmf[i, z] = temp;

                                temp2 = BZ[j];
                                BZ[j] = BZ[z];
                                BZ[z] = temp2;
                            }
                        }
                    }
                }
                k2 = 0;
                for (int i2 = 0; i2 < 5; i2++)
                {
                    int j2 = int.Parse(BZ[i2].ToString());
                    k2 = i2 + 1;
                    pm = k2.ToString();
                    PMmon[j2 - 1] = pm;
                }
                if (jlm[i, 0] == jlmf[i, 1] && jlmf[i, 0] == jlmf[i, 2] && jlmf[i, 0] == jlmf[i, 3] && jlmf[i, 0] == jlmf[i, 4])
                {
                    for (int i5 = 0; i5 < 5; i5++)
                    {
                        PMmon[i5] = "1";
                    }
                }
                #endregion
                k2 = 0;
                for (int k = 0; k < 5; k++)
                {
                    if (PMmon[k] == "5")
                    {
                        k2 = k;
                    }
                }
                djine = 500 - (((double.Parse(jlmf2[i, k2]) - khz[i]) / 0.1) * 50);
                if (djine < 0)
                {
                    djine = 0;
                }
                else if (djine > 500)
                {
                    djine = 500;
                }
                for (int k = 0; k < 5; k++)//计算奖金
                {
                    switch (PMmon2[k])
                    {
                        case "1":
                            jine[i + 2, k] = djine * 0.4;
                            break;
                        case "2":
                            jine[i + 2, k] = djine * 0.3;
                            break;
                        case "3":
                            jine[i + 2, k] = djine * 0.2;
                            break;
                        case "4":
                            jine[i + 2, k] = djine * 0.1;
                            break;
                        case "5":
                            jine[i + 2, k] = 0;
                            break;
                    }
                    jine[i + 2, 5] = jine[i + 2, 5] + jine[i + 2, k];
                }
                #endregion
                for (int k = 0; k < 6; k++)
                {
                    sb.AppendFormat("<td  align=\"center\">{0}</td>", jine[i + 2,k].ToString());
                }
                sb.Append("</tr>");
            }
            #region 计算奖金总额
            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    jine[10, i] = jine[10, i] + jine[j, i];
                }
            }
            #endregion
            sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\" bgcolor=\"#CFE6FC\" colspan=\"2\">奖金总额</td>");
            for (int i = 0; i < 6; i++)
            {
                sb.AppendFormat("<td  align=\"center\">{0}</td>", jine[10,i].ToString());
            }
            sb.Append("</tr>");

            return sb.ToString();

        }

        /// <summary>
        /// 年累计排名
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetLJByYear(DateTime date)
        {
            ArrayList listYB = new ArrayList();
            ArrayList DlistYB = new ArrayList();
            string[] res = new string[12];
            string[] res2 = new string[12];
            string[] qsrq = new string[12];
            string[] jsrq = new string[12];
            string[] jldt = new string[24];
            string[,] jlm = new string[24, 6];//小指标累计值
            string[,] defen = new string[10, 5];
            double[] pjdf = new double[5];
            string[,] PMmon2 = new string[13,5];//小指标总排名
            string[] jldt2 = new string[10];
            string[][] arr = new string[12][];
            string[,] BZ = new string[12,5];
            string[][] DL = new string[12][];
            string[,] DLPMmon = new string[13,5];
            string[] PMLJ = new string[5];
            string[] BZLJ = new string[]{"1","2","3","4","5" };
            string[] DLPMyear = new string[5];
            string temp;
            string repName1 = "小指标考核";
            string repName2 = "发电量奖";
            string bNameY = "统计数据值月表";
            string bzIDY;
            int t;
            string temp2;
            double temp3;
            DateTime dtNow = DateTime.Now;

            if (dtNow.Year < date.Year)
            { sb.Append("请输入正确时间查询..."); return sb.ToString(); }

            if (dtNow.Year == date.Year)
            {
                for (int i = 0; i < dtNow.Month-1; i++)
                {
                    t = dtNow.Month - i - 1;
                    qsrq[i] = sh.FirstDayOfMonth(dtNow.AddMonths(-t)).ToString("yyyy-MM-dd 00:00:00");
                    jsrq[i] = sh.LastDayOfMonth(dtNow.AddMonths(-t)).ToString("yyyy-MM-dd 23:59:59");
                    //res[i] = dpqr.retPowerByMonth(repName2, qsrq[i], jsrq[i]);
                    DlistYB = dpqr.RetArrsRepValDay("zy", "发电量奖", qsrq[i], jsrq[i], bNameY, "0", out bzIDY);
                    jldt = (string[])DlistYB[3];
                    res2[i] = (string)jldt[3];
                    #region 计算小指考核
                    listYB = dpqr.RetArrsRepValDay("zy", "小指标考核", qsrq[i], jsrq[i], bNameY, "0", out bzIDY);
                    jldt = (string[])listYB[3];
                    for (int ii = 1; ii < 24; ii++)
                    {
                        jldt2 = jldt[ii].TrimEnd(',').Split(',');
                        for (int j = 0; j < jldt2.Count(); j++)
                        {
                            jlm[ii, j] = jldt2[j];
                        }
                    }
                    #region 统计各个得分
                    for (int k = 0; k < 4; k++)
                    {
                        for (int k1 = 0; k1 < 5; k1++)
                        {
                            defen[k, k1] = jlm[k * 2 + 2, k1];
                        }
                    }
                    for (int k = 0; k < 5; k++)//主蒸汽温度
                    {
                        if (double.Parse(jlm[9, k]) <= 545)
                        {
                            defen[4, k] = jlm[10, k];
                        }
                        else
                        {
                            defen[4, k] = jlm[11, k];
                        }
                    }

                    for (int k = 0; k < 5; k++)//再热器温度
                    {
                        if (double.Parse(jlm[12, k]) <= 545)
                        {
                            defen[5, k] = jlm[13, k];
                        }
                        else
                        {
                            defen[5, k] = jlm[14, k];
                        }
                    }
                    for (int k = 0; k < 5; k++)
                    {
                        defen[6, k] = jlm[16, k];
                    }
                    for (int k = 0; k < 5; k++)//排烟温度
                    {
                        if (double.Parse(jlm[17, k]) <= 545)
                        {
                            defen[7, k] = jlm[18, k];
                        }
                        else
                        {
                            defen[7, k] = jlm[19, k];
                        }
                    }
                    for (int k = 0; k < 2; k++)
                    {
                        for (int k1 = 0; k1 < 5; k1++)
                        {
                            defen[k + 8, k1] = jlm[k * 2 + 21, k1];
                        }
                    }
                    #endregion
                    for (int i1 = 0; i1 < 5; i1++)//计算总得分
                    {
                        temp3 = 0;
                        for (int j = 0; j < 10; j++)
                        {
                            temp3 = temp3 + double.Parse(defen[j, i1]);
                        }
                        pjdf[i1] = temp3 / 10;
                    }
                    //pjdf[0] = 2; pjdf[1] = 1; pjdf[2] = 5; pjdf[3] = 4; pjdf[4] = 3;//测试
                    #region 计算总排名
                    string temp22;
                    string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };
                    
                    for (int j3 = 0; j3 < 5; j3++)
                    {
                        for (int z3 = 4; z3 > j3; z3--)
                        {
                            if (pjdf[j3] != 0 && pjdf[j3] != 0)
                            {
                                if (pjdf[j3] < pjdf[z3])
                                {
                                    temp3 = pjdf[j3];
                                    pjdf[j3] = pjdf[z3];
                                    pjdf[z3] = temp3;

                                    temp22 = BZ2[j3];
                                    BZ2[j3] = BZ2[z3];
                                    BZ2[z3] = temp22;
                                }
                            }
                        }
                    }
                    int k22 = 0;
                    string pm2;
                    temp3 = 0;
                    for (int i22 = 0; i22 < 5; i22++)
                    {
                        int j22 = int.Parse(BZ2[i22].ToString());
                        k22 = i22 + 1;
                        pm2 = k22.ToString();
                        PMmon2[i,j22 - 1] = pm2;
                    }

                    if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
                    {
                        for (int i4 = 0; i4 < 5; i4++)
                        {
                            PMmon2[i,i4] = "1";
                        }
                    }
                    #endregion

                    #endregion
                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    qsrq[i] = sh.FirstDayOfMonth(date.AddMonths(i)).ToString("yyyy-MM-dd H:mm:ss");
                    jsrq[i] = sh.LastDayOfMonth(date.AddMonths(i)).ToString("yyyy-MM-dd 23:59:59");
                    //res[i] = dpqr.retPowerByMonth(repName2, qsrq[i], jsrq[i]);
                    DlistYB = dpqr.RetArrsRepValDay("zy", "发电量奖", qsrq[i], jsrq[i], bNameY, "0", out bzIDY);
                    jldt = (string[])listYB[3];
                    res2[i] = (string)jldt[3];
                    #region 计算小指考核
                    listYB = dpqr.RetArrsRepValDay("zy", "小指标考核", qsrq[i], jsrq[i], bNameY, "0", out bzIDY);
                    jldt = (string[])listYB[3];
                    for (int ii = 1; ii < 24; ii++)
                    {
                        jldt2 = jldt[ii].TrimEnd(',').Split(',');
                        for (int j = 0; j < jldt2.Count(); j++)
                        {
                            jlm[ii, j] = jldt2[j];
                        }
                    }
                    #region 统计各个得分
                    for (int k = 0; k < 4; k++)
                    {
                        for (int k1 = 0; k1 < 5; k1++)
                        {
                            defen[k, k1] = jlm[k * 2 + 2, k1];
                        }
                    }
                    for (int k = 0; k < 5; k++)//主蒸汽温度
                    {
                        if (double.Parse(jlm[9, k]) <= 545)
                        {
                            defen[4, k] = jlm[10, k];
                        }
                        else
                        {
                            defen[4, k] = jlm[11, k];
                        }
                    }

                    for (int k = 0; k < 5; k++)//再热器温度
                    {
                        if (double.Parse(jlm[12, k]) <= 545)
                        {
                            defen[5, k] = jlm[13, k];
                        }
                        else
                        {
                            defen[5, k] = jlm[14, k];
                        }
                    }
                    for (int k = 0; k < 5; k++)
                    {
                        defen[6, k] = jlm[16, k];
                    }
                    for (int k = 0; k < 5; k++)//排烟温度
                    {
                        if (double.Parse(jlm[17, k]) <= 545)
                        {
                            defen[7, k] = jlm[18, k];
                        }
                        else
                        {
                            defen[7, k] = jlm[19, k];
                        }
                    }
                    for (int k = 0; k < 2; k++)
                    {
                        for (int k1 = 0; k1 < 5; k1++)
                        {
                            defen[k + 8, k1] = jlm[k * 2 + 21, k1];
                        }
                    }
                    #endregion
                    for (int i1 = 0; i1 < 5; i1++)//计算总得分
                    {
                        temp3 = 0;
                        for (int j = 0; j < 10; j++)
                        {
                            temp3 = temp3 + double.Parse(defen[j, i1]);
                        }
                        pjdf[i1] = temp3 / 10;
                    }
                    //pjdf[0] = 2; pjdf[1] = 1; pjdf[2] = 5; pjdf[3] = 4; pjdf[4] = 3;//测试
                    #region 计算总排名
                    string temp22;
                    string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };

                    for (int j3 = 0; j3 < 5; j3++)
                    {
                        for (int z3 = 4; z3 > j3; z3--)
                        {
                            if (pjdf[j3] != 0 && pjdf[j3] != 0)
                            {
                                if (pjdf[j3] < pjdf[z3])
                                {
                                    temp3 = pjdf[j3];
                                    pjdf[j3] = pjdf[z3];
                                    pjdf[z3] = temp3;

                                    temp22 = BZ2[j3];
                                    BZ2[j3] = BZ2[z3];
                                    BZ2[z3] = temp22;
                                }
                            }
                        }
                    }
                    int k22 = 0;
                    string pm2;
                    temp3 = 0;
                    for (int i22 = 0; i22 < 5; i22++)
                    {
                        int j22 = int.Parse(BZ2[i22].ToString());
                        k22 = i22 + 1;
                        pm2 = k22.ToString();
                        PMmon2[i, j22 - 1] = pm2;
                    }

                    if (pjdf[0] == pjdf[1] && pjdf[0] == pjdf[2] && pjdf[0] == pjdf[3] && pjdf[0] == pjdf[4])
                    {
                        for (int i4 = 0; i4 < 5; i4++)
                        {
                            PMmon2[i, i4] = "1";
                        }
                    }
                    #endregion

                    #endregion
                }
            }
            
            if (res != null)
            {
                #region 计算小指标考核年累计排名                
                double[] PMmon3=new double[5];
                for (int i = 0; i < 5; i++)
                {
                    temp3 = 0;
                    for (int j = 0; j < 12; j++)
                    {
                        if (PMmon2[j, i] != null && PMmon2[j, i].ToString() != "")
                        {
                            temp3 = temp3 + double.Parse(PMmon2[j, i]);
                        }
                        else
                        {
                            temp3 = temp3 + 0;
                        }
                    }
                    PMmon3[i] = temp3;
                }
                #region 计算总排名
                string temp22;
                string[] BZ2 = new string[5] { "1", "2", "3", "4", "5" };

                for (int j3 = 0; j3 < 5; j3++)
                {
                    for (int z3 = 4; z3 > j3; z3--)
                    {
                        if (PMmon3[j3] != 0 && PMmon3[j3] != 0)
                        {
                            if (PMmon3[j3] > PMmon3[z3])
                            {
                                temp3 = PMmon3[j3];
                                PMmon3[j3] = PMmon3[z3];
                                PMmon3[z3] = temp3;

                                temp22 = BZ2[j3];
                                BZ2[j3] = BZ2[z3];
                                BZ2[z3] = temp22;
                            }
                        }
                    }
                }
                int k22 = 0;
                string pm2;
                for (int i22 = 0; i22 < 5; i22++)
                {
                    int j22 = int.Parse(BZ2[i22].ToString());
                    k22 = i22 + 1;
                    pm2 = k22.ToString();
                    PMmon2[12, j22 - 1] = pm2;
                }
                if (PMmon3[0] == PMmon3[1] && PMmon3[0] == PMmon3[2] && PMmon3[0] == PMmon3[3] && PMmon3[0] == PMmon3[4])
                {
                    for (int i4 = 0; i4 < 5; i4++)
                    {
                        PMmon2[12, i4] = "1";
                    }
                }
                #endregion
                #endregion
                #region 计算发电量奖
                for (int i = 0; i < 12; i++)
                {
                    if (res2[i] != null)
                    {
                        //arr[i] = res[i].Split('|');
                        //BZ[i] = arr[i][0].TrimEnd(',').Split(',');
                        //DL[i] = arr[i][1].TrimEnd(',').Split(',');
                        DL[i] = res2[i].TrimEnd(',').Split(',');
                        BZ[i,0] = "1"; BZ[i,1] = "2"; BZ[i,2] = "3"; BZ[i,3] = "4"; BZ[i,4] = "5";

                        for (int y = 0; y < DL[i].Length; y++)
                        {
                            for (int x = DL[i].Length - 1; x > y; x--)
                            {
                                if (DL[i][x] != null && DL[i][y] != null)
                                {
                                    if (double.Parse(DL[i][y]) < double.Parse(DL[i][x]))
                                    {
                                        temp = DL[i][y];
                                        DL[i][y] = DL[i][x];
                                        DL[i][x] = temp;

                                        temp = BZ[i,y];
                                        BZ[i,y] = BZ[i,x];
                                        BZ[i,x] = temp;
                                    }
                                }
                            }
                        }
                        int k = 0;
                        string pm;
                        if (DL[i][0] == DL[i][1] && DL[i][0] == DL[i][2] && DL[i][0] == DL[i][3] && DL[i][0] == DL[i][4])
                        {
                            for (int x = 0; x < 5; x++)
                            {
                                DLPMmon[i,x] = "1";
                            }
                        }
                        else
                        {
                            for (int x = 0; x < 5; x++)
                            {
                                int y = int.Parse(BZ[i,x].ToString());
                                k = x + 1;
                                pm = k.ToString();
                                DLPMmon[i, y - 1] = pm;
                            }
                        }
                    }                  
                }
                
                for (int u = 0; u < 5; u++)
                {
                    double n = 0;
                    for (int v = 0; v < 12; v++)
                    {
                        if (DLPMmon[v, u] != null)
                        {
                            n = double.Parse(DLPMmon[v, u].ToString()) + n;
                        }
                    }
                    PMLJ[u] = n.ToString();
                }
                for (int j = 0; j < PMLJ.Length; j++)
                {
                    for (int i = PMLJ.Length-1; i > j; i--)
                    {
                        if (PMLJ[i] != null && PMLJ[j] != null)
                        {
                            if (double.Parse(PMLJ[j]) > double.Parse(PMLJ[i]))
                            {
                                temp = PMLJ[j];
                                PMLJ[j] = PMLJ[i];
                                PMLJ[i] = temp;

                                temp = BZLJ[j];
                                BZLJ[j] = BZLJ[i];
                                BZLJ[i] = temp;
                            }
                        }
                    }
                }
                int w = 0;
                string dlpm;
                if (PMLJ[0] == PMLJ[1] && PMLJ[0] == PMLJ[2] && PMLJ[0] == PMLJ[3] && PMLJ[0] == PMLJ[4])
                {
                    for (int x = 0; x < PMLJ.Length; x++)
                    {
                        DLPMmon[12, x] = "1";
                    }
                }
                else
                {
                    for (int i = 0; i < BZLJ.Length; i++)
                    {
                        int j = int.Parse(BZLJ[i].ToString());
                        w = i + 1;
                        dlpm = w.ToString();
                        DLPMmon[12, j - 1] = dlpm;
                    }
                }
            #endregion
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td colspan=\"14\" align=\"center\" >小指标年累计排名</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td  align=\"center\">月份</td><td  align=\"center\">1月</td><td  align=\"center\">2月</td><td  align=\"center\">3月</td><td  align=\"center\">4月</td><td  align=\"center\">5月</td><td  align=\"center\">6月</td><td  align=\"center\">7月</td><td  align=\"center\">8月</td><td  align=\"center\">9月</td><td  align=\"center\">10月</td><td  align=\"center\">11月</td><td  align=\"center\">12月</td><td  align=\"center\">年累计</td></tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">一值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (PMmon2[i, 0] != null && PMmon2[i, 0] != "")
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>",PMmon2[i,0]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">二值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (PMmon2[i, 1] != null && PMmon2[i, 1] != "")
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i, 1]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">三值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (PMmon2[i, 2] != null && PMmon2[i, 2] != "")
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i, 2]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">四值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (PMmon2[i, 3] != null && PMmon2[i, 3] != "")
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i, 3]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">五值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (PMmon2[i, 4] != null && PMmon2[i, 4] != "")
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", PMmon2[i, 4]);
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");


                sb.Append("<tr bgcolor=\"#CFE6FC\"><td colspan=\"14\" align=\"center\" >电量年累计排名</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td  align=\"center\">月份</td><td  align=\"center\">1月</td><td  align=\"center\">2月</td><td  align=\"center\">3月</td><td  align=\"center\">4月</td><td  align=\"center\">5月</td><td  align=\"center\">6月</td><td  align=\"center\">7月</td><td  align=\"center\">8月</td><td  align=\"center\">9月</td><td  align=\"center\">10月</td><td  align=\"center\">11月</td><td  align=\"center\">12月</td><td  align=\"center\">年累计</td></tr>");

                #region 电量年累计排名展示
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">一值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (DLPMmon[i, 0] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", DLPMmon[i, 0].ToString());
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">二值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (DLPMmon[i, 0] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", DLPMmon[i, 1].ToString());
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">三值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (DLPMmon[i, 0] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", DLPMmon[i, 2].ToString());
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">四值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (DLPMmon[i, 0] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", DLPMmon[i, 3].ToString());
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                sb.Append("<tr bgcolor=\"#FFFFFF\"><td  align=\"center\">五值</td>");
                for (int i = 0; i < 13; i++)
                {
                    if (DLPMmon[i, 0] != null)
                    {
                        sb.AppendFormat("<td  align=\"center\">{0}</td>", DLPMmon[i, 4].ToString());
                    }
                    else
                    {
                        sb.Append("<td  align=\"center\">-</td>");
                    }
                }
                sb.Append("</tr>");
                #endregion
            }

            else
                sb.Append("查询出错,请联系管理员解决...");

            return sb.ToString();
        }
    }
}
